//
//  UIButton+Extension.swift
//  微博项目
//
//  Created by 原晓桢 on 15/11/3.
//  Copyright © 2015年 itcast.cn. All rights reserved.
//

import UIKit

extension UIButton {
    convenience init (imageName: String, backImageName: String){
        self.init()
        
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
        
        //自动调整frame
        sizeToFit()
    }
    
    convenience init (title: String, color: UIColor, imageName: String) {
        self.init()
        
        setTitle(title, forState: .Normal)
        setTitleColor(color, forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named:imageName), forState: .Normal)
    }
}
